﻿using System;

namespace DBMock.Builders.Attributes
{
    /// <summary>
    /// 日期builder特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class DateBuilderAttribute : BaseBuilderAttribute
    {
        /// <summary>
        /// 初始化DateBuilderAttribute
        /// </summary>
        /// <param name="minDate">最小日期</param>
        /// <param name="maxDate">最大日期</param>
        public DateBuilderAttribute(string minDate = "1753.1.1", string maxDate = "9999.12.31")
            : base(typeof(DateBuilder))
        {
            DateTime min;
            DateTime max;

            if (!DateTime.TryParse(minDate, out min))
            { min = new DateTime(1753, 1, 1); }

            if (!DateTime.TryParse(maxDate, out max))
            { max = new DateTime(9999, 12, 31); }

            para = new object[] { min, max };
        }
    }
}
